package main

import "fmt"

// 抽象层
type Car interface {
	Run()
}

type Driver interface {
	Drive(car Car)
}

// 实现层
type Benz struct {
}

func (b *Benz) Run() {
	fmt.Println("Benz is running...")
}

type BMW struct {
}

func (m *BMW) Run() {
	fmt.Println("BMW is running...")
}

type ZhangSan struct {
}

func (zs *ZhangSan) Drive(car Car) {
	fmt.Println("张三 开车...")
	car.Run()
}

type LiSi struct {
}

func (ls *LiSi) Drive(car Car) {
	fmt.Println("李四 开车")
	car.Run()
}

// 业务逻辑层
func main() {
	// zhangsan 开奔驰
	var benz Car
	benz = new(Benz)

	var zhangsan Driver
	zhangsan = new(ZhangSan)
	zhangsan.Drive(benz)

	//李四开宝马
	var bmw Car
	bmw = new(BMW)
	var lisi Driver
	lisi = new(LiSi)
	lisi.Drive(bmw)

	//张三开宝马
	zhangsan.Drive(bmw)
	//李四开奔驰
	lisi.Drive(benz)
}
